home *** CD-ROM | disk | FTP | other *** search
/ Champak 106 / Vol 106.iso / games / rain_for.swf / scripts / __Packages / smashing / Menu.as < prev    next >
Encoding:
Text File  |  2010-04-12  |  3.0 KB  |  117 lines

  1. class smashing.Menu extends MovieClip
  2. {
  3.    var startTime;
  4.    var limit;
  5.    var onEnterFrame;
  6.    static var target;
  7.    var bEnabled = true;
  8.    function Menu()
  9.    {
  10.       super();
  11.       smashing.Menu.target = this;
  12.    }
  13.    function onShow()
  14.    {
  15.    }
  16.    function onResume()
  17.    {
  18.    }
  19.    function show(sFrame)
  20.    {
  21.       this.onShow();
  22.       this.gotoAndPlay(sFrame);
  23.    }
  24.    function resume()
  25.    {
  26.       this.gotoAndStop("blank");
  27.       this.onResume();
  28.    }
  29.    function playAgain()
  30.    {
  31.    }
  32.    static function watchProp(o, sProp, sType)
  33.    {
  34.       switch(sType)
  35.       {
  36.          case "text":
  37.             o.watch(sProp,smashing.Menu.watchText);
  38.             break;
  39.          case "frameMeter":
  40.             o.watch(sProp,smashing.Menu.watchFrameMeter);
  41.             break;
  42.          case "pegboard":
  43.             o.watch(sProp,smashing.Menu.watchPegboard);
  44.             break;
  45.          case "signboard":
  46.             o.watch(sProp,smashing.Menu.watchSignboard);
  47.             break;
  48.          case "singleDigit":
  49.             o.watch(sProp,smashing.Menu.watchSingleDigit);
  50.             break;
  51.          case "funkyMeter":
  52.             o.watch(sProp,smashing.Menu.watchFunkyMeter);
  53.       }
  54.    }
  55.    static function watchText(prop, oldVal, newVal)
  56.    {
  57.       smashing.Menu.target[prop.toString()] = newVal;
  58.       return newVal;
  59.    }
  60.    static function watchFrameMeter(prop, oldVal, newVal)
  61.    {
  62.       var _loc2_ = smashing.Menu.target[prop.toString()];
  63.       var _loc1_ = Math.ceil(newVal * _loc2_._totalframes);
  64.       if(_loc1_ == 0)
  65.       {
  66.          _loc1_ = 1;
  67.       }
  68.       _loc2_.gotoAndStop(_loc1_);
  69.       return newVal;
  70.    }
  71.    static function watchPegboard(prop, oldVal, newVal)
  72.    {
  73.       var _loc1_ = smashing.Menu.target[prop.toString()];
  74.       _loc1_.pegs = newVal;
  75.       return newVal;
  76.    }
  77.    static function watchSignboard(prop, oldVal, newVal)
  78.    {
  79.       var _loc4_ = 1;
  80.       var _loc2_ = smashing.Menu.target[prop.toString()];
  81.       _loc2_.gotoAndStop(newVal);
  82.       _loc2_.startTime = getTimer();
  83.       _loc2_.limit = _loc4_;
  84.       _loc2_.onEnterFrame = function()
  85.       {
  86.          var _loc2_ = (getTimer() - this.startTime) / 1000;
  87.          if(_loc2_ >= this.limit)
  88.          {
  89.             this._visible = false;
  90.             delete this.onEnterFrame;
  91.          }
  92.       };
  93.       return newVal;
  94.    }
  95.    static function watchSingleDigit(prop, oldVal, newVal)
  96.    {
  97.       var _loc1_ = smashing.Menu.target[prop.toString()];
  98.       _loc1_.gotoAndStop(newVal + 1);
  99.       smashing.Menu.target[prop + "cache"] = newVal + 1;
  100.       return newVal;
  101.    }
  102.    static function watchFunkyMeter(prop, oldVal, newVal)
  103.    {
  104.       if(newVal < 0)
  105.       {
  106.          newVal = 0;
  107.       }
  108.       var _loc2_ = smashing.Menu.target.funkyMeter;
  109.       var _loc1_ = _loc2_[prop.toString()];
  110.       var _loc4_ = _loc2_[prop.toString() + "Cap"];
  111.       _loc1_._width = newVal * _loc1_.fullWidth;
  112.       _loc4_._x = _loc1_._x + _loc1_._width - _loc4_._width / 2;
  113.       _loc2_[prop.toString() + "Cache"] = newVal;
  114.       return newVal;
  115.    }
  116. }
  117.